﻿<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log4net"
             type="log4net.Config.Log4NetConfigurationSectionHandler" />
  </configSections>
  <log4net>
    <root>
      <level value="ALL" />
      <appender-ref ref="AdoNetAppender" />
      <appender-ref ref="ConsoleAppender" />
      <appender-ref ref="FileAppender" />
    </root>
    <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
      <!--BufferSize为缓冲区大小-->
      <bufferSize value="100" />
      <connectionType value="System.Data.SQLite.SQLiteConnection, System.Data.SQLite, Version=1.0.92.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
      <connectionString value="Data Source=E:\\DataBase\\log4net.db;Version=3;" />
      <commandText value="INSERT INTO Log ([Date],[Level],[Namespace],[Method], [File],[Rows],[Thread],[Logger],[Message]) VALUES (@Date, @Level, @Namespace,@Method,@File,@Rows,@Thread,@Logger, @Message)" />
      <parameter>
        <parameterName value="@Date" />
        <dbType value="DateTime" />
        <layout type="log4net.Layout.RawTimeStampLayout" />
      </parameter>
      <parameter>
        <parameterName value="@Level" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%level" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Namespace" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%C" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Method" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%M" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@File" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%F" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Rows" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%l" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Thread" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%t" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Logger" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%M" />
        </layout>
      </parameter>
      <parameter>
        <parameterName value="@Message" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%message" />
        </layout>
      </parameter>
    </appender>
    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">    
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="[时间:%date]%newline[级别:%level]%newline[命名空间:%C]%newline[方法:%M]%newline[文件名:%F]%newline[行数:%l]%newline[线程名:%t]%newline[logger:%M]%newline[消息:%message]%newline%newline" />
      </layout>
    </appender>
    <appender name="FileAppender" type="log4net.Appender.FileAppender">
      <file value="log-file.txt" />
      <appendToFile value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="[时间:%date]%newline[级别:%level]%newline[命名空间:%C]%newline[方法:%M]%newline[文件名:%F]%newline[行数:%l]%newline[线程名:%t]%newline[logger:%M]%newline[消息:%message]%newline%newline" />
      </layout>
    </appender>
  </log4net>
</configuration>